home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
amiga
/
GadTools.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
24KB
|
686 lines
(***************************************************************************
$RCSfile: GadTools.mod $
Description: Interface to gadtools.library
Created by: fjc (Frank Copeland)
$Revision: 3.8 $
$Author: fjc $
$Date: 1995/06/04 23:13:14 $
Includes Release 40.15
(C) Copyright 1989-1993 Commodore-Amiga, Inc.
All Rights Reserved
Oberon-A interface Copyright © 1994-1995, Frank Copeland.
This file is part of the Oberon-A Interface.
See Oberon-A.doc for conditions of use and distribution.
***************************************************************************)
<* STANDARD- *>
MODULE [2] GadTools;
IMPORT
SYS := SYSTEM, Kernel, e := Exec, u := Utility, gfx := Graphics,
i := Intuition, s := Sets;
(*
** $VER: gadtools.h 39.9 (19.8.92)
**
** gadtools.library definitions
*)
(* -----------------------------------------------------------------------*)
(* The kinds (almost classes) of gadgets in the toolkit. Use these
identifiers when calling CreateGadgetA() *)
CONST
genericKind * = 0;
buttonKind * = 1;
checkBoxKind * = 2;
integerKind * = 3;
listViewKind * = 4;
mxKind * = 5;
numberKind * = 6;
cycleKind * = 7;
paletteKind * = 8;
scrollerKind * = 9;
(* Kind number 10 is reserved *)
sliderKind * = 11;
stringKind * = 12;
textKind * = 13;
numKinds * = 14;
(* -----------------------------------------------------------------------*)
CONST
(* 'Or' the appropriate set together for your Window IDCMPFlags: *)
arrowIDCMP * = { i.gadgetUp, i.gadgetDown, i.intuiTicks,
i.mouseButtons };
buttonIDCMP * = { i.gadgetUp };
checkBoxIDCMP * = { i.gadgetUp };
integerIDCMP * = { i.gadgetUp };
listViewIDCMP * = { i.gadgetUp, i.gadgetDown, i.mouseMove }
+ arrowIDCMP;
mxIDCMP * = { i.gadgetDown };
numberIDCMP * = {};
cycleIDCMP * = { i.gadgetUp };
paletteIDCMP * = { i.gadgetUp };
(* Use ArrowIDCMP + ScrollerIDCMP if your scrollers have arrows: *)
scrollerIDCMP * = { i.gadgetUp, i.gadgetDown, i.mouseMove };
sliderIDCMP * = { i.gadgetUp, i.gadgetDown, i.mouseMove };
stringIDCMP * = { i.gadgetUp };
textIDCMP * = {};
(* -----------------------------------------------------------------------*)
TYPE
VisualInfo * = POINTER TO RECORD END;
(* Generic NewGadget used by several of the gadget classes: *)
NewGadgetPtr * = POINTER TO NewGadget;
NewGadget * = RECORD
leftEdge *,
topEdge * : INTEGER; (* gadget position *)
width *,
height * : INTEGER; (* gadget size *)
gadgetText * : e.LSTRPTR; (* gadget label *)
textAttr * : gfx.TextAttrPtr; (* desired font for gadget label *)
gadgetID * : e.UWORD; (* gadget ID *)
flags * : s.SET32; (* see below *)
visualInfo * : VisualInfo; (* Set to retval of GetVisualInfo() *)
userData * : e.APTR; (* gadget UserData *)
END; (* NewGadget *)
CONST
(* flags control certain aspects of the gadget. The first five control
* the placement of the descriptive text. Each gadget kind has its default,
* which is usually placeTextLeft. Consult the autodocs for details.
*)
placeTextLeft * = 0; (* Right-align text on left side *)
placeTextRight * = 1; (* Left-align text on right side *)
placeTextAbove * = 2; (* Center text above *)
placeTextBelow * = 3; (* Center text below *)
placeTextIn * = 4; (* Center text on *)
highLabel * = 5; (* Highlight the label *)
(* -----------------------------------------------------------------------*)
TYPE
(* Fill out an array of these and pass that to CreateMenus(): *)
NewMenuPtr * = POINTER TO NewMenu;
NewMenu * = RECORD
type * : SHORTINT; (* See below *)
(* Compiler inserts a PAD byte here *)
label * : e.LSTRPTR; (* Menu's label *)
commKey * : e.LSTRPTR; (* MenuItem Command Key Equiv *)
flags * : s.SET16; (* Menu or MenuItem flags (see note) *)
mutualExclude * : s.SET32; (* MenuItem MutualExclude word *)
userData * : e.APTR; (* For your own use, see note *)
END; (* NewMenu *)
CONST
(* Needed only by inside im* definitions below *)
menuImage * = -128;
(* type determines what each NewMenu structure corresponds to.
* for the nmTitle, nmItem, and nmSub values, label should
* be a text string to use for that menu title, item, or sub-item.
* For imItem or imSub, set label to point at the Image structure
* you wish to use for this item or sub-item.
* NOTE: At present, you may only use conventional images.
* Custom images created from Intuition image-classes do not work.
*)
title * = 1;
item * = 2;
sub * = 3;
imItem * = item + menuImage;
imSub * = sub + menuImage;
(* The NewMenu array should be terminated with a NewMenu whose
* type equals nmEnd.
*)
end * = 0; (* End of NewMenu array *)
(* Starting with V39, GadTools will skip any NewMenu entries whose
* ype field has the nmIgnore bit set.
*)
ignore * = 64;
(* nm_Label should be a text string for textual items, a pointer
* to an Image structure for graphical menu items, or the special
* constant nmBarlabel, to get a separator bar.
*)
barLabel * = SYS.VAL(e.LSTRPTR, -1);
(* The nmFlags field is used to fill out either the Menu.flags or
MenuItem.flags field. Note that the sense of the menuEnabled or
itemEnabled bit is inverted between this use and Intuition's use,
in other words, NewMenus are enabled by default. The following
labels are provided to disable them: *)
menuDisabled * = i.menuEnabled;
itemDisabled * = i.itemEnabled;
(* New for V39: nmCommandString. For a textual MenuItem or SubItem,
* point commKey at an arbitrary string, and set the nmCommandString
* flag.
*)
commandString * = i.commSeq;
(* The following are pre-cleared (commSeq, itemText, and highxxx are set
* later as appropriate):
* Under V39, the commSeq flag bit is not cleared, since it now has
* meaning.
*)
flagMask * = -({i.commSeq, i.itemText} + i.highFlags);
flagMaskV39 * = -({i.itemText} + i.highFlags);
(* You may choose among checkIt, menuToggle, and checked.
Toggle-select menuitems are of type checkIt | menuToggle, along
with checked if currently selected. Mutually exclusive ones
are of type checkIt, and possibly checked too. The nmMutualExclude
is a bit-wise representation of the items excluded by this one,
so in the simplest case (choose 1 among n), these flags would be
~1, ~2, ~4, ~8, ~16, etc. See the Intuition Menus chapter. *)
(* A UserData pointer can be associated with each Menu and MenuItem structure.
* The CreateMenus() call allocates space for a UserData after each
* Menu or MenuItem (header, item or sub-item). You should use the
* GTMENU_USERDATA() or GTMENUITEM_USERDATA() macro to extract it.
*)
(*
#define GTMENU_USERDATA(menu) ( * ( (APTR * )(((struct Menu * )menu)+1) ) )
#define GTMENUITEM_USERDATA(menuitem) ( * ( (APTR * )(((struct MenuItem * )menuitem)+1) ) )
(* Here is an old one for compatibility. Do not use in new code! *)
#define MENU_USERDATA(menuitem) ( * ( (APTR * )(menuitem+1) ) )
*)
(* These return codes can be obtained through the gtmnSecondaryError tag *)
gtMenuTrimmed * = 00000001H; (* Too many menus, items, or subitems,
menu has been trimmed down *)
gtMenuInvalid * = 00000002H; (* Invalid NewMenu array *)
gtMenuNoMem * = 00000003H; (* Out of memory *)
(*------------------------------------------------------------------------*)
(* Starting with V39, checkboxes and mx gadgets can be scaled to your
* specified gadget width/height. Use the new cbScaled or mxScaled
* tags, respectively. Under V37, and by default in V39, the imagery
* is of the following fixed size:
*)
CONST
(* MX gadget default dimensions: *)
mxWidth * = 17;
mxHeight * = 9;
(* Checkbox default dimensions: *)
checkboxWidth * = 26;
checkboxHeight * = 11;
(* -----------------------------------------------------------------------*)
CONST
(* Tags for GadTools functions: *)
tagBase * = u.user + 80000H;
viNewWindow * = tagBase+1; (* Unused *)
viNWTags * = tagBase+2; (* Unused *)
Private0 = tagBase+3; (* (private) *)
cbChecked * = tagBase+4; (* State of checkbox *)
lvTop * = tagBase+5; (* Top visible one in listview *)
lvLabels * = tagBase+6; (* List to display in listview *)
noList * = SYS.VAL(e.ListPtr,-1); (* for short list locking (see RKMs) *)
lvReadOnly * = tagBase+7; (* TRUE if listview is to be
* read-only
*)
lvScrollWidth * = tagBase+8; (* Width of scrollbar *)
mxLabels * = tagBase+9; (* NULL-terminated array of labels *)
mxActive * = tagBase+10; (* Active one in mx gadget *)
txText * = tagBase+11; (* Text to display *)
txCopyText * = tagBase+12; (* Copy text label instead of
* referencing it
*)
nmNumber * = tagBase+13; (* Number to display *)
cyLabels * = tagBase+14; (* NULL-terminated array of labels *)
cyActive * = tagBase+15; (* The active one in the cycle gad *)
paDepth * = tagBase+16; (* Number of bitplanes in palette *)
paColor * = tagBase+17; (* Palette color *)
paColorOffset * = tagBase+18; (* First color to use in palette *)
paIndicatorWidth * = tagBase+19; (* Width of current-color indicator *)
paIndicatorHeight * = tagBase+20; (* Height of current-color indicator *)
scTop * = tagBase+21; (* Top visible in scroller *)
scTotal * = tagBase+22; (* Total in scroller area *)
scVisible * = tagBase+23; (* Number visible in scroller *)
scOverlap * = tagBase+24; (* Unused *)
(* tagBase+25 through tagBase+37 are reserved *)
slMin * = tagBase+38; (* Slider min value *)
slMax * = tagBase+39; (* Slider max value *)
slLevel * = tagBase+40; (* Slider level *)
slMaxLevelLen * = tagBase+41; (* Max length of printed level *)
slLevelFormat * = tagBase+42; (* Format string for level *)
slLevelPlace * = tagBase+43; (* Where level should be placed *)
slDispFunc * = tagBase+44; (* Callback for number calculation
* before display
*)
stString * = tagBase+45; (* String gadget's displayed string *)
stMaxChars * = tagBase+46; (* Max length of string *)
inNumber * = tagBase+47; (* Number in integer gadget *)
inMaxChars * = tagBase+48; (* Max number of digits *)
mnTextAttr * = tagBase+49; (* MenuItem font TextAttr *)
mnFrontPen * = tagBase+50; (* MenuItem text pen color *)
bbRecessed * = tagBase+51; (* Make BevelBox recessed *)
visualInfo * = tagBase+52; (* result of VisualInfo call *)
lvShowSelected * = tagBase+53; (* show selected entry beneath
* listview, set tag data = NULL for display-only, or pointer
* to a string gadget you've created
*)
lvSelected * = tagBase+54; (* Set ordinal number of selected
* entry in the list
*)
Reserved1 = tagBase+56; (* Reserved for future use *)
txBorder * = tagBase+57; (* Put a border around
* Text-display gadgets
*)
nmBorder * = tagBase+58; (* Put a border around
* Number-display gadgets
*)
scArrows * = tagBase+59; (* Specify size of arrows for
* scroller
*)
mnMenu * = tagBase+60; (* Pointer to Menu for use by
* LayoutMenuItems()
*)
mxSpacing * = tagBase+61; (* Added to font height to
* figure spacing between mx choices. Use this instead
* of layoutaSpacing for mx gadgets.
*)
(* New to V37 GadTools. Ignored by GadTools V36 *)
fullMenu * = tagBase+62; (* Asks CreateMenus() to
* validate that this is a complete menu structure
*)
secondaryError * = tagBase+63; (* tiData is a pointer
* to a ULONG to receive error reports from CreateMenus()
*)
underscore * = tagBase+64; (* tiData points to the symbol
* that preceeds the character you'd like to underline in a
* gadget label
*)
stEditHook * = tagBase+55; (* String EditHook *)
inEditHook * = stEditHook; (* Same thing, different name,
* just to round out integerKind gadgets
*)
(* New to V39 GadTools. Ignored by GadTools V36 and V37 *)
mnCheckmark * = tagBase+65; (* data is checkmark img to use *)
mnAmigaKey * = tagBase+66; (* data is Amiga-key img to use *)
mnNewLookMenus * = tagBase+67; (* data is boolean *)
(* New to V39 GadTools. Ignored by GadTools V36 and V37.
* Set to TRUE if you want the checkbox or mx image scaled to
* the gadget width/height you specify. Defaults to FALSE,
* for compatibility.
*)
cbScaled * = tagBase+68; (* data is boolean *)
mxScaled * = tagBase+69; (* data is boolean *)
paNumColors * = tagBase+70; (* Number of colors in palette *)
mxTitlePlace * = tagBase+71; (* Where to put the title *)
txFrontPen * = tagBase+72; (* Text color in textKind gad *)
txBackPen * = tagBase+73; (* Bgrnd color in textKind gad *)
txJustification * = tagBase+74; (* See j#? constants *)
nmFrontPen * = tagBase+72; (* Text color in numberKind gad *)
nmBackPen * = tagBase+73; (* Bgrnd color in numberKind gad *)
nmJustification * = tagBase+74; (* See j#? constants *)
nmFormat * = tagBase+75; (* Formatting string for number *)
nmMaxNumberLen * = tagBase+76; (* Maximum length of number *)
bbFrameType * = tagBase+77; (* defines what kind of boxes
* DrawBevelBox() renders. See
* the bbft#? constants for
* possible values
*)
lvMakeVisible * = tagBase+78; (* Make this item visible *)
lvItemHeight * = tagBase+79; (* Height of an individual item *)
slMaxPixelLen * = tagBase+80; (* Max pixel size of level display *)
slJustification * = tagBase+81; (* how should the level be displayed *)
paColorTable * = tagBase+82; (* colors to use in palette *)
lvCallBack * = tagBase+83; (* general-purpose listview call back *)
lvMaxPen * = tagBase+84; (* maximum pen number used by call back *)
txClipped * = tagBase+85; (* make a textKind clip text *)
nmClipped * = tagBase+85; (* make a numberKind clip text *)
(* Old definition, now obsolete: *)
Reserved0 * = stEditHook;
(*------------------------------------------------------------------------*)
(* Justification types for txJustification and nmJustification tags *)
jLeft * = 0;
jRight * = 1;
jCenter * = 2;
(*------------------------------------------------------------------------*)
(* Bevel box frame types for bbFrameType tag *)
bbftButton * = 1; (* Standard button gadget box *)
bbftRidge * = 2; (* Standard string gadget box *)
bbftIconDropBox * = 3; (* Standard icon drop box *)
(* -----------------------------------------------------------------------*)
CONST
(* Typical suggested spacing between "elements": *)
interWidth * = 8;
interHeight * = 4;
(* -----------------------------------------------------------------------*)
CONST
(* "NWay" is an old synonym for cycle gadgets *)
nWAYKind * = cycleKind;
nWAYIDCMP * = cycleIDCMP;
nwLabels * = cyLabels;
nwActive * = cyActive;
(*------------------------------------------------------------------------*)
(* These two definitions are obsolete, but are here for backwards
* compatibility. You never need to worry about these:
*)
gadToolBit * = 15;
(* Use this mask to isolate the user part: *)
gadToolMask * = -{gadToolBit};
(*------------------------------------------------------------------------*)
(* These definitions are for the LV_CallBack tag *)
(* The different types of messages that a listview callback hook can see *)
lvDraw * = 0202H; (* draw yourself, with state *)
(* Possible return values from a callback hook *)
lvcbOk * = 0; (* callback understands this message type *)
lvcbUnknown * = 1; (* callback does not understand this message *)
(* states for LVDrawMsg.state *)
lvrNormal * = 0; (* the usual *)
lvrSelected * = 1; (* for selected gadgets *)
lvrNormalDisabled * = 2; (* for disabled gadgets *)
lvrSelectedDisabled * = 8; (* disabled and selected *)
TYPE
(* structure of lvDraw messages, object is an Exec.NodePtr *)
LVDrawMsg * = RECORD (i.MsgBase)
msg * : i.Msg; (* lvDraw *)
rastPort * : gfx.RastPortPtr; (* where to render to *)
drawInfo * : i.DrawInfoPtr; (* useful to have around *)
bounds * : gfx.Rectangle; (* limits of where to render *)
state * : e.ULONG; (* how to render *)
END;
(**-- Library Base variable --------------------------------------------*)
CONST
gadtoolsName * = "gadtools.library";
VAR
base * : e.LibraryPtr;
(**-- Library Functions ------------------------------------------------*)
(*
** $VER: gadtools_protos.h 39.2 (24.3.92)
*)
(* --- functions in V36 or higher (distributed as Release 2.0) ---*)
(* Gadget Functions *)
PROCEDURE CreateGadgetA* [base,-30]
( kind [0] : e.ULONG;
gad [8] : i.GadgetPtr;
VAR ng [9] : NewGadget;
taglist [10] : ARRAY OF u.TagItem )
: i.GadgetPtr;
PROCEDURE CreateGadget* [base,-30]
( kind [0] : e.ULONG;
gad [8] : i.GadgetPtr;
VAR ng [9] : NewGadget;
taglist [10].. : u.Tag )
: i.GadgetPtr;
PROCEDURE FreeGadgets* [base,-36]
( gad [8] : i.GadgetPtr );
PROCEDURE SetGadgetAttrsA* [base,-42]
( VAR gad [8] : i.Gadget;
win [9] : i.WindowPtr;
req [10] : i.RequesterPtr;
taglist [11] : ARRAY OF u.TagItem );
PROCEDURE SetGadgetAttrs* [base,-42]
( VAR gad [8] : i.Gadget;
win [9] : i.WindowPtr;
req [10] : i.RequesterPtr;
taglist [11].. : u.Tag );
(* Menu functions *)
PROCEDURE CreateMenusA* [base,-48]
( newmenu [8] : ARRAY OF NewMenu;
taglist [9] : ARRAY OF u.TagItem )
: i.MenuPtr;
PROCEDURE CreateMenus* [base,-48]
( newmenu [8] : ARRAY OF NewMenu;
taglist [9].. : u.Tag )
: i.MenuPtr;
PROCEDURE CreateMenusAB* [base,-48]
( newmenu [8] : NewMenuPtr;
taglist [9] : ARRAY OF u.TagItem )
: i.MenuPtr;
PROCEDURE CreateMenusB* [base,-48]
( newmenu [8] : NewMenuPtr;
taglist [9].. : u.Tag )
: i.MenuPtr;
PROCEDURE FreeMenus* [base,-54]
( menu [8] : i.MenuPtr );
PROCEDURE LayoutMenuItemsA* [base,-60]
( firstitem [8] : i.MenuItemPtr;
vi [9] : VisualInfo;
taglist [10] : ARRAY OF u.TagItem )
: BOOLEAN;
PROCEDURE LayoutMenuItems* [base,-60]
( firstitem [8] : i.MenuItemPtr;
vi [9] : VisualInfo;
taglist [10].. : u.Tag )
: BOOLEAN;
PROCEDURE LayoutMenusA* [base,-66]
( firstmenu [8] : i.MenuPtr;
vi [9] : VisualInfo;
taglist [10] : ARRAY OF u.TagItem )
: BOOLEAN;
PROCEDURE LayoutMenus* [base,-66]
( firstmenu [8] : i.MenuPtr;
vi [9] : VisualInfo;
taglist [10].. : u.Tag )
: BOOLEAN;
(* Misc Event-Handling Functions *)
PROCEDURE GetIMsg* [base,-72]
( iport [8] : e.MsgPortBasePtr )
: i.IntuiMessagePtr;
PROCEDURE ReplyIMsg* [base,-78]
( imsg [9] : i.IntuiMessageBasePtr );
PROCEDURE RefreshWindow* [base,-84]
( win [8] : i.WindowPtr;
req [9] : i.RequesterPtr );
PROCEDURE BeginRefresh* [base,-90]
( win [8] : i.WindowPtr );
PROCEDURE EndRefresh* [base,-96]
( win [8] : i.WindowPtr;
complete [0] : i.LONGBOOL );
PROCEDURE FilterIMsg* [base,-102]
( imsg [9] : i.IntuiMessageBasePtr )
: i.IntuiMessagePtr;
PROCEDURE PostFilterIMsg* [base,-108]
( imsg [8] : i.IntuiMessageBasePtr )
: i.IntuiMessagePtr;
PROCEDURE CreateContext* [base,-114]
( VAR glistptr [8] : i.GadgetPtr )
: i.GadgetPtr;
(* Rendering Functions *)
PROCEDURE DrawBevelBoxA* [base,-120]
( rport [8] : gfx.RastPortPtr;
left [0] : LONGINT;
top [1] : LONGINT;
width [2] : LONGINT;
height [3] : LONGINT;
taglist [9] : ARRAY OF u.TagItem );
PROCEDURE DrawBevelBox* [base,-120]
( rport [8] : gfx.RastPortPtr;
left [0] : LONGINT;
top [1] : LONGINT;
width [2] : LONGINT;
height [3] : LONGINT;
taglist [9].. : u.Tag );
(* Visuals Functions *)
PROCEDURE GetVisualInfoA* [base,-126]
( screen [8] : i.ScreenPtr;
taglist [9] : ARRAY OF u.TagItem )
: VisualInfo;
PROCEDURE GetVisualInfo* [base,-126]
( screen [8] : i.ScreenPtr;
taglist [9].. : u.Tag )
: VisualInfo;
PROCEDURE FreeVisualInfo* [base,-132]
( vi [8] : VisualInfo );
(*--- functions in V39 or higher (Release 3) ---*)
PROCEDURE GetGadgetAttrsA* [base,-174]
( gad [8] : i.GadgetPtr;
win [9] : i.WindowPtr;
req [10] : i.RequesterPtr;
taglist [11] : ARRAY OF u.TagItem )
: LONGINT;
PROCEDURE GetGadgetAttrs* [base,-174]
( gad [8] : i.GadgetPtr;
win [9] : i.WindowPtr;
req [10] : i.RequesterPtr;
taglist [11]..: u.Tag )
: LONGINT;
(**-- C Macros defined as procedures -----------------------------------*)
<*$LongVars+*>
(* A UserData pointer can be associated with each Menu and MenuItem structure.
The CreateMenus() call allocates space for a UserData after each
Menu or MenuItem (header, item or sub-item). You should use the
gtMenuUSERDATA() or gtMenuitemUSERDATA() macro to extract it. *)
(**-----------------------------------*)
PROCEDURE [0] MenuUserData * (menu : i.MenuPtr) : e.APTR;
BEGIN (* MenuUserData *)
RETURN SYS.VAL (e.APTR, SYS.VAL (LONGINT, menu) + SIZE (i.Menu))
END MenuUserData;
(**-----------------------------------*)
PROCEDURE [0] MenuItemUserData * (menuitem : i.MenuItemPtr) : e.APTR;
BEGIN (* MenuItemUserData *)
RETURN
SYS.VAL (e.APTR, SYS.VAL (LONGINT, menuitem) + SIZE (i.MenuItem))
END MenuItemUserData;
(**-- Library Base variable --------------------------------------------*)
<*$LongVars-*>
(**-----------------------------------*)
PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
BEGIN (* CloseLib *)
IF base # NIL THEN e.CloseLibrary (base) END
END CloseLib;
BEGIN
base := e.OpenLibrary (gadtoolsName, e.libraryMinimum);
IF base # NIL THEN Kernel.SetCleanup (CloseLib) END
END GadTools.